/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.navid.trafalgar.definition;

import com.google.gson.Gson;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetLoader;
import java.io.ByteArrayOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;

/**
 *
 * @author alberto
 */
public class JsonAssetLoader implements AssetLoader {

    public Object load(AssetInfo assetInfo) throws IOException {
        
        Reader r =new InputStreamReader(assetInfo.openStream());
        GameDefinition game = new Gson().fromJson(r, GameDefinition.class);
        r.close();
        
        return game;

    }
    
}
